package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.Constants;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppGameGiftRecord;
import com.vf.admin.miaodong.service.AfterGameGiftRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 砸蛋游戏记录
 */
@Controller
@RequestMapping("/after/gamegift")
public class AfterGameGiftRecordController extends BaseController{

    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    AfterGameGiftRecordService afterGameGiftRecordService;


    /**
     * 砸蛋游戏记录列表
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate   结束时间
     * @param gametype  类型  1银蛋   2金蛋  3钻石蛋
     * @param giftname  礼物名称
     * @param nick  用户昵称
     * @param phone  用户手机号
     * @return
     */
    @RequestMapping("/list")
    public String list(SplitPageBean splitPageBean,String startDate,String endDate,Integer gametype,String giftname,
                    String nick,String phone){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("gametype",gametype);
            map.put("giftname",giftname);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppGameGiftRecord> list = afterGameGiftRecordService.list(map,splitPageBean);

            //类型  1银蛋   2金蛋  3钻石蛋
            Map<Integer,String> gametypeMap = Constants.getZdlxMap();
            request.setAttribute("gametypeMap",gametypeMap);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("gametype",gametype);
            request.setAttribute("giftname",giftname);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/after/gamegift/list");
        }catch (Exception e){
            logger.error("查询砸蛋游戏记录异常",e);
            return this.error("系统繁忙");
        }
    }

}
